Add and hook in gtk_calendar_scroll, to let the mouse wheels select the
authorMatthias Clasen <maclas@gmx.de>
Fri, 8 Aug 2003 22:03:25 +0000 (22:03 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 8 Aug 2003 22:03:25 +0000 (22:03 +0000)
2003-08-09  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkcalendar.c:  Add and hook in gtk_calendar_scroll,
to let the mouse wheels select the month. Scrolling down
moves forward in time. (#53134, Abigail Brady)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcalendar.c

index a52c735d998eedd092418b30183ac58eeee062e6..e01daa82dcbc53027b37d03b9a49ac4164ef2851 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,13 @@
+2003-08-09  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkcalendar.c:  Add and hook in gtk_calendar_scroll,
+       to let the mouse wheels select the month. Scrolling down
+       moves forward in time. (#53134, Abigail Brady) 
+
 2003-08-08  Matthias Clasen  <maclas@gmx.de>
 
-       * gdk/gdkregion-generic.c (gdk_region_spans_intersect_foreach): Fix a segfault.  (#115284, 
-       Jan Kratochvil) 
+       * gdk/gdkregion-generic.c (gdk_region_spans_intersect_foreach): Fix 
+       a segfault.  (#115284, Jan Kratochvil) 
 
 2003-08-08  Tor Lillqvist  <tml@iki.fi>
 
index a52c735d998eedd092418b30183ac58eeee062e6..e01daa82dcbc53027b37d03b9a49ac4164ef2851 100644 (file)
@@ -1,7 +1,13 @@
+2003-08-09  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkcalendar.c:  Add and hook in gtk_calendar_scroll,
+       to let the mouse wheels select the month. Scrolling down
+       moves forward in time. (#53134, Abigail Brady) 
+
 2003-08-08  Matthias Clasen  <maclas@gmx.de>
 
-       * gdk/gdkregion-generic.c (gdk_region_spans_intersect_foreach): Fix a segfault.  (#115284, 
-       Jan Kratochvil) 
+       * gdk/gdkregion-generic.c (gdk_region_spans_intersect_foreach): Fix 
+       a segfault.  (#115284, Jan Kratochvil) 
 
 2003-08-08  Tor Lillqvist  <tml@iki.fi>
 
index a52c735d998eedd092418b30183ac58eeee062e6..e01daa82dcbc53027b37d03b9a49ac4164ef2851 100644 (file)
@@ -1,7 +1,13 @@
+2003-08-09  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkcalendar.c:  Add and hook in gtk_calendar_scroll,
+       to let the mouse wheels select the month. Scrolling down
+       moves forward in time. (#53134, Abigail Brady) 
+
 2003-08-08  Matthias Clasen  <maclas@gmx.de>
 
-       * gdk/gdkregion-generic.c (gdk_region_spans_intersect_foreach): Fix a segfault.  (#115284, 
-       Jan Kratochvil) 
+       * gdk/gdkregion-generic.c (gdk_region_spans_intersect_foreach): Fix 
+       a segfault.  (#115284, Jan Kratochvil) 
 
 2003-08-08  Tor Lillqvist  <tml@iki.fi>
 
index a52c735d998eedd092418b30183ac58eeee062e6..e01daa82dcbc53027b37d03b9a49ac4164ef2851 100644 (file)
@@ -1,7 +1,13 @@
+2003-08-09  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkcalendar.c:  Add and hook in gtk_calendar_scroll,
+       to let the mouse wheels select the month. Scrolling down
+       moves forward in time. (#53134, Abigail Brady) 
+
 2003-08-08  Matthias Clasen  <maclas@gmx.de>
 
-       * gdk/gdkregion-generic.c (gdk_region_spans_intersect_foreach): Fix a segfault.  (#115284, 
-       Jan Kratochvil) 
+       * gdk/gdkregion-generic.c (gdk_region_spans_intersect_foreach): Fix 
+       a segfault.  (#115284, Jan Kratochvil) 
 
 2003-08-08  Tor Lillqvist  <tml@iki.fi>
 
index a52c735d998eedd092418b30183ac58eeee062e6..e01daa82dcbc53027b37d03b9a49ac4164ef2851 100644 (file)
@@ -1,7 +1,13 @@
+2003-08-09  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkcalendar.c:  Add and hook in gtk_calendar_scroll,
+       to let the mouse wheels select the month. Scrolling down
+       moves forward in time. (#53134, Abigail Brady) 
+
 2003-08-08  Matthias Clasen  <maclas@gmx.de>
 
-       * gdk/gdkregion-generic.c (gdk_region_spans_intersect_foreach): Fix a segfault.  (#115284, 
-       Jan Kratochvil) 
+       * gdk/gdkregion-generic.c (gdk_region_spans_intersect_foreach): Fix 
+       a segfault.  (#115284, Jan Kratochvil) 
 
 2003-08-08  Tor Lillqvist  <tml@iki.fi>
 
index 5faa39c3efe9a226354d99c9209024718179e010..4c0dbb3e218fae15b395934ac1443e40829a14e9 100644 (file)
@@ -313,6 +313,8 @@ static gint gtk_calendar_leave_notify       (GtkWidget *widget,
                                         GdkEventCrossing *event);
 static gint gtk_calendar_key_press     (GtkWidget         *widget,
                                         GdkEventKey       *event);
+static gint gtk_calendar_scroll         (GtkWidget         *widget,
+                                        GdkEventScroll    *event);
 static void gtk_calendar_grab_notify    (GtkWidget          *widget,
                                         gboolean            was_grabbed);
 static void gtk_calendar_state_changed (GtkWidget *widget,
@@ -400,6 +402,7 @@ gtk_calendar_class_init (GtkCalendarClass *class)
   widget_class->enter_notify_event = gtk_calendar_enter_notify;
   widget_class->leave_notify_event = gtk_calendar_leave_notify;
   widget_class->key_press_event = gtk_calendar_key_press;
+  widget_class->scroll_event = gtk_calendar_scroll;
   widget_class->style_set = gtk_calendar_style_set;
   widget_class->state_changed = gtk_calendar_state_changed;
   widget_class->grab_notify = gtk_calendar_grab_notify;
@@ -1203,7 +1206,7 @@ gtk_calendar_realize (GtkWidget *widget)
   attributes.wclass = GDK_INPUT_OUTPUT;
   attributes.window_type = GDK_WINDOW_CHILD;
   attributes.event_mask =  (gtk_widget_get_events (widget) 
-                           | GDK_EXPOSURE_MASK |GDK_KEY_PRESS_MASK);
+                           | GDK_EXPOSURE_MASK |GDK_KEY_PRESS_MASK | GDK_SCROLL_MASK);
   attributes.visual = gtk_widget_get_visual (widget);
   attributes.colormap = gtk_widget_get_colormap (widget);
   
@@ -2895,6 +2898,30 @@ gtk_calendar_finalize (GObject *object)
     (* G_OBJECT_CLASS (parent_class)->finalize) (object);
 }
 
+static gboolean
+gtk_calendar_scroll (GtkWidget      *widget,
+                    GdkEventScroll *event)
+{
+  GtkCalendar *calendar = GTK_CALENDAR (widget);
+
+  if (event->direction == GDK_SCROLL_UP) 
+    {
+      if (!GTK_WIDGET_HAS_FOCUS (widget))
+       gtk_widget_grab_focus (widget);
+      gtk_calendar_set_month_prev (calendar);
+    }
+  else if (event->direction == GDK_SCROLL_DOWN) 
+    {
+      if (!GTK_WIDGET_HAS_FOCUS (widget))
+       gtk_widget_grab_focus (widget);
+      gtk_calendar_set_month_next (calendar);
+    }
+  else
+    return FALSE;
+
+  return TRUE;
+}
+
 static gboolean
 gtk_calendar_key_press (GtkWidget   *widget,
                        GdkEventKey *event)